<?php
require_once("header.php");

if(!$Auth->checkAuth()) {

echo json_encode(array('error' => 1));

exit;

}



//latest 3 downloads
	//get 3 last downloads from offer process
$arr = getLatestDownloads($uid, 3);

	
//latest 3 downloads

  $io = 0;
  if(count($arr) > 0){
  while($io < 3)
  {
	  if(!empty($arr[$io]['country']))
	  $rr .= '<div class="pseparator2" style="height:30px; font-size:18px; font-family:TitilliumText14L; background-position:top; width:98%; padding-top:10px; text-align:center; margin:0px auto" title="Downloaded on '.$arr[$io]['date'].'">'.$arr[$io]['time'].'&nbsp;&nbsp;&nbsp;<img src="'.SITE_URL.'flags/'.strtolower($arr[$io]['country']).'.gif" />&nbsp;&nbsp;&nbsp;$'.$arr[$io]['credits'].'</div>';
	  
	  $io++;
  }
  }else
  {
	  $rr .= '<div class="pseparator2" style="height:30px; font-size:18px; font-family:TitilliumText14L; background-position:top; width:98%; padding-top:10px; text-align:center; margin:0px auto" >N/A</div>';
  }


if(empty($today____clicks))
$today____clicks = "0";


if(empty($today_earnings))
$today_earnings = "0.00";

if(empty($today_downloads))
$today_downloads = "0";

if(empty($avgcpa))
$avgcpa = "0.00";

if(empty($total_earnings))
$total_earnings = "0.00";


if(empty($month_earnings))
$month_earnings = "0.00";



echo json_encode(array('clicks' => $today____clicks, 'earnings' => $today_earnings, 'downloads' => $today_downloads, 'avgcpa' => $avgcpa, 'rank' => $myRank['rank'], 'goal' => $myRank['goal'], 'recent' => $rr, 'month_earnings' => $month_earnings, 'total_earnings' => $total_earnings));



return;


?>